from django.http import HttpResponse
from django.template import Context, loader, RequestContext
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.db.models import Q
from lib.models import *

@login_required
def index(request):
  user = UserProfile.objects.get(user=request.user)
  feedPosts = FeedPost.objects.filter(Q(to_user__in=user.friends.all()) | Q(from_user__in=user.friends.all()))
  c = RequestContext(request, { 'posts':feedPosts })
  t = loader.get_template('home/index.html')
  return HttpResponse(t.render(c))
  
def addStatus(request):
  return redirect('/home/')
